package cn.tedu.mvc;

import com.sun.org.apache.xalan.internal.xsltc.compiler.util.StringStack;
import org.junit.Test;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

@RestController
@RequestMapping("get")
public class GetController {
    // 测试 http://localhost:8080/get/param4?id=3&name=保时捷&type=param&color=black&price=999.9
    @RequestMapping("param4")
    public Car param4(Car c) {
        return c;
    }

    // http://localhost:8080/get/param?id=1&name=张三&age=18
    @RequestMapping("param")
    public String param(int id) {
        return "请求的参数是" + id;
    }

    @RequestMapping("param2")
    public String param2(int a, int b) {
        return "请求的参数是" + a + b;
    }

    @Test
    public void get1() {
        String url = "http://localhost:8080/car/insert?id=1&name=张三&age=18";
        String[] strs = url.split("\\?")[1].split("&");
        System.out.println(Arrays.toString(strs));
        for (String str: strs) {
            System.out.println(str.split("=")[1]);

        }


    }
}
